package com.project.yuepai.util;

import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;

public class EmailUtil {

    public static boolean pushCodeToEmail(JavaMailSender javaMailSender,String toUser,String code){
        try{
            SimpleMailMessage message = new SimpleMailMessage();
            message.setFrom("hzu-lai@qq.com");
            message.setTo(toUser);
            message.setSubject("今日宜学习");
            message.setText("验证码为："+code+"\n请在五分钟内完成操作，五分钟后无效！");
            javaMailSender.send(message);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
}
